/*
 * Universidad del Valle de Guatemala
 * Departamento de Ciencias de la Computacion
 * Algoritmos y Estructuras de Datos
 * Hoja de Trabajo 5
 * David Coronado, 07325
 */

/**
 *
 * @author David Coronado
 */
public class DriverProgram {

    public static void main(String[] args){

        //Instances of the both implementations
        Heap_Implementation<Integer> heap_queue = new Heap_Implementation();
        JFC_Implementation<Integer> JCF_queue = new JFC_Implementation();

        //Array that holds the 1000 random numbers
        int random[] = new int[1000];

        /**
         * Generates 1000 random numbers between 1 and 999 and stores them in
         * the random array.
         */
        for(int i=0; i < 1000; i++) {
            random[i]=(int) (Math.random() * 999 + 1);
            heap_queue.add(random[i]);
            JCF_queue.add(random[i]);
        }

        int firstelement, lastelement=0;

        firstelement = heap_queue.remove();

        //removes the elements off the queue and stores the last one
        while(!heap_queue.isEmpty()){
            lastelement = heap_queue.remove();
        }

        System.out.println("*************************************************");
        System.out.println("*               Hoja de Trabajo 5               *");
        System.out.println("*     Implementación de colas con prioridad.    *");
        System.out.println("*************************************************");
        System.out.println();

        System.out.println("*************************************************");
        System.out.println("\nImplementacion con Heaps:");
        System.out.println("\n      Primer Elemento en salir: " + firstelement);
        System.out.println("      Ultimo Elemento en salir: " + lastelement);

        firstelement = JCF_queue.remove();

        while(!heap_queue.isEmpty()){
            lastelement = JCF_queue.remove();
        }

        System.out.println("\n*************************************************");
        System.out.println("\nImplementacion con PriorityQueues de JCF:");
        System.out.println("\n      Primer Elemento en salir: " + firstelement);
        System.out.println("      Ultimo Elemento en salir: " + lastelement);
        System.out.println("\n*************************************************");
    }

}
